package com.itheima.security.springboot.service;

import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * <p>
 * SpringDataUserDetailsService
 * </p>
 *
 * @author flyduck
 * @since 2023/11/19
 */
@Service
public class SpringDataUserDetailsService implements UserDetailsService {
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        //登录账号
        System.out.println("username=" + username);//根据账号去数据库查询...
        //这里暂时使用静态数据
        UserDetails userDetails =
                User.withUsername(username).password("$2a$10$FiDbUMZj9hlq7RMuG22k0udHKUle2l0OgwTT81TjP9G5Q5yUrfz9C").authorities("p1").build();
        return userDetails;
    }
}
